<?php if (!defined('THINK_PATH')) exit();?>
<!DOCTYPE html>
<html lang="en">
	<head>
    	<meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	    <meta name="viewport" content="width=device-width, initial-scale=1">
	    <title>Proton - Admin Template</title>

		<!-- Import google fonts - Heading first/ text second -->
        <link rel='stylesheet' type='text/css' />
        <!--[if lt IE 9]>
<link href="http://fonts.useso.com/css?family=Open+Sans:400" rel="stylesheet" type="text/css" />
<link href="http://fonts.useso.com/css?family=Open+Sans:700" rel="stylesheet" type="text/css" />
<link href="http://fonts.useso.com/css?family=Droid+Sans:400" rel="stylesheet" type="text/css" />
<link href="http://fonts.useso.com/css?family=Droid+Sans:700" rel="stylesheet" type="text/css" />
<![endif]-->

		<!-- Fav and touch icons -->
		<link rel="shortcut icon" href="/Public/Admin/assets/ico/favicon.ico" type="image/x-icon" />

	    <!-- Css files -->
	    <link href="/Public/Admin/assets/css/bootstrap.min.css" rel="stylesheet">
		<link href="/Public/Admin/assets/css/jquery.mmenu.css" rel="stylesheet">
		<link href="/Public/Admin/assets/css/font-awesome.min.css" rel="stylesheet">
		<link href="/Public/Admin/assets/css/climacons-font.css" rel="stylesheet">
		<link href="/Public/Admin/assets/plugins/xcharts/css/xcharts.min.css" rel=" stylesheet">
		<link href="/Public/Admin/assets/plugins/fullcalendar/css/fullcalendar.css" rel="stylesheet">
		<link href="/Public/Admin/assets/plugins/morris/css/morris.css" rel="stylesheet">
		<link href="/Public/Admin/assets/plugins/jquery-ui/css/jquery-ui-1.10.4.min.css" rel="stylesheet">
		<link href="/Public/Admin/assets/plugins/jvectormap/css/jquery-jvectormap-1.2.2.css" rel="stylesheet">
	    <link href="/Public/Admin/assets/css/style.min.css" rel="stylesheet">
		<link href="/Public/Admin/assets/css/add-ons.min.css" rel="stylesheet">



		<link href="/Public/Admin/layui/css/layui.css" rel="stylesheet">



	    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
	    <!--[if lt IE 9]>
			<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
			<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
	    <![endif]-->
	    <!-- 头部区块 -->
	    
	    <style type="text/css">
	    	.error{ color:red; font-size:12px; font-weight: normal;}
	    	.a{text-decoration:none;}
	    	.a:hover{text-decoration:none;}
	    </style>
	</head>
</head>

<body>
	<!-- start: Header -->
	<div class="navbar" role="navigation">

		<div class="container-fluid">

			<ul class="nav navbar-nav navbar-actions navbar-left">
				<li class="visible-md visible-lg"><a href="index.html#" id="main-menu-toggle"><i class="fa fa-th-large"></i></a></li>
				<li class="visible-xs visible-sm"><a href="index.html#" id="sidebar-menu"><i class="fa fa-navicon"></i></a></li>
			</ul>

			<form class="navbar-form navbar-left">
				<button type="submit" class="fa fa-search"></button>
				<input type="text" class="form-control" placeholder="Search..."></a>
			</form>
			<div class="copyrights">Collect from <a href="http://www.cssmoban.com/" >免费模板</a></div>
	        <ul class="nav navbar-nav navbar-right">
				<li class="dropdown visible-md visible-lg">
	        		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-envelope-o"></i><span class="badge">5</span></a>
	        		<ul class="dropdown-menu">
						<li class="dropdown-menu-header">
							<strong>Messages</strong>
							<div class="progress thin">
							  <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" style="width: 30%">
							    <span class="sr-only">30% Complete (success)</span>
							  </div>
							</div>
						</li>
						<li class="avatar">
							<a href="page-inbox.html">
								<img class="avatar" src="/Public/Admin/assets/img/avatar1.jpg">
								<div>New message</div>
								<small>1 minute ago</small>
								<span class="label label-info">NEW</span>
							</a>
						</li>
						<li class="avatar">
							<a href="page-inbox.html">
								<img class="avatar" src="/Public/Admin/assets/img/avatar2.jpg">
								<div>New message</div>
								<small>3 minute ago</small>
								<span class="label label-info">NEW</span>
							</a>
						</li>
						<li class="avatar">
							<a href="page-inbox.html">
								<img class="avatar" src="/Public/Admin/assets/img/avatar3.jpg">
								<div>New message</div>
								<small>4 minute ago</small>
								<span class="label label-info">NEW</span>
							</a>
						</li>
						<li class="avatar">
							<a href="page-inbox.html">
								<img class="avatar" src="/Public/Admin/assets/img/avatar4.jpg">
								<div>New message</div>
								<small>30 minute ago</small>
							</a>
						</li>
						<li class="avatar">
							<a href="page-inbox.html">
								<img class="avatar" src="/Public/Admin/assets/img/avatar5.jpg">
								<div>New message</div>
								<small>1 hours ago</small>
							</a>
						</li>
						<li class="dropdown-menu-footer text-center">
							<a href="page-inbox.html">View all messages</a>
						</li>
	        		</ul>
	      		</li>
				<li class="dropdown visible-md visible-lg">
	        		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-bell-o"></i><span class="badge">3</span></a>
	        		<ul class="dropdown-menu">
						<li class="dropdown-menu-header">
							<strong>Notifications</strong>
							<div class="progress thin">
							  <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" style="width: 30%">
							    <span class="sr-only">30% Complete (success)</span>
							  </div>
							</div>
						</li>
                        <li class="clearfix">
							<i class="fa fa-comment"></i>
                            <a href="page-activity.html" class="notification-user"> Sharon Rose </a>
                            <span class="notification-action"> replied to your </span>
                            <a href="page-activity.html" class="notification-link"> comment</a>
                        </li>
                        <li class="clearfix">
                            <i class="fa fa-pencil"></i>
                            <a href="page-activity.html" class="notification-user"> Nadine </a>
                            <span class="notification-action"> just write a </span>
                            <a href="page-activity.html" class="notification-link"> post</a>
                        </li>
                        <li class="clearfix">
                            <i class="fa fa-trash-o"></i>
                            <a href="page-activity.html" class="notification-user"> Lorenzo </a>
                            <span class="notification-action"> just remove <a href="#" class="notification-link"> 12 files</a></span>
                        </li>
						<li class="dropdown-menu-footer text-center">
							<a href="page-activity.html">View all notification</a>
						</li>
	        		</ul>
	      		</li>
				<li class="dropdown visible-md visible-lg">
					 <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-gears"></i></a>
					<ul class="dropdown-menu update-menu" role="menu">
						<li><a href="#"><i class="fa fa-database"></i> Database </a>
                        </li>
                        <li><a href="#"><i class="fa fa-bar-chart-o"></i> Connection </a>
                        </li>
                        <li><a href="#"><i class="fa fa-bell"></i> Notification </a>
                        </li>
                        <li><a href="#"><i class="fa fa-envelope"></i> Message </a>
                        </li>
                        <li><a href="#"><i class="fa fa-flash"></i> Traffic </a>
                        </li>
						<li><a href="#"><i class="fa fa-credit-card"></i> Invoices </a>
                        </li>
                        <li><a href="#"><i class="fa fa-dollar"></i> Finances </a>
                        </li>
                        <li><a href="#"><i class="fa fa-thumbs-o-up"></i> Orders </a>
                        </li>
						<li><a href="#"><i class="fa fa-folder"></i> Directories </a>
                        </li>
                        <li><a href="#"><i class="fa fa-users"></i> Users </a>
                        </li>
					</ul>
				</li>
				<li class="dropdown visible-md visible-lg">
	        		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><img class="user-avatar" src="/Public/Admin/assets/img/avatar.jpg" alt="user-mail"><?php echo ($_SESSION['admin_user']['realname']); ?></a>
	        		<ul class="dropdown-menu">
						<li class="dropdown-menu-header">
							<strong>Account</strong>
						</li>
						<li><a href="page-profile.html"><i class="fa fa-user"></i> Profile</a></li>
						<li><a href="page-login.html"><i class="fa fa-wrench"></i> Settings</a></li>
						<li><a href="page-invoice.html"><i class="fa fa-usd"></i> Payments <span class="label label-default">10</span></a></li>
						<li><a href="gallery.html"><i class="fa fa-file"></i> File <span class="label label-primary">27</span></a></li>
						<li class="divider"></li>
						<li><a href="<?php echo U('Admin/admin/logout');?>"><i class="fa fa-sign-out"></i>退出</a></li>
	        		</ul>
	      		</li>
				<li><a href="<?php echo U('Admin/admin/logout');?>"><i class="fa fa-power-off"></i></a></li>
			</ul>

		</div>

	</div>
	<!-- end: Header -->

	<div class="container-fluid content">

		<div class="row">

			<!-- start: Main Menu -->
			<div class="sidebar ">

				<div class="sidebar-collapse">
					<div class="sidebar-header t-center">
                        <span><img class="text-logo" src="/Public/Admin/assets/img/logo1.png"><i class="fa fa-space-shuttle fa-3x blue"></i></span>
                    </div>
					<div class="sidebar-menu">
						<ul class="nav nav-sidebar">
							<li><a href="index.html"><i class="fa fa-laptop"></i><span class="text"> Dashboard</span></a></li>

							<?php if(is_array($top_nav)): foreach($top_nav as $key=>$v): if(in_array($v['id'],$_SESSION['admin_user']['group_access'])){ ?>
							<li>
								<a href="#">
									<i class="fa <?php echo ($v["icon"]); ?>"></i>
									<span class="text"><?php echo ($v["name"]); ?></span>
									<span class="fa fa-angle-down pull-right"></span>
								</a>

                                <ul class="nav sub">
								<?php if(is_array($child_nav)): foreach($child_nav as $key=>$v1): if(in_array($v1['id'],$_SESSION['admin_user']['group_access'])){ ?>
								  <?php if(($v['id']) == $v1['pid']): ?><li>
									  <a href="<?php echo U($v1['url']);?>">
										  <i class="fa <?php echo ($v1["icon"]); ?>"></i>
										  <span class="text"><?php echo ($v1["name"]); ?></span>
									  </a>
								  </li><?php endif; ?>
								<?php } endforeach; endif; ?>
								</ul>

							</li>
							<?php } endforeach; endif; ?>

						</ul>
					</div>
				</div>
				<div class="sidebar-footer">

					<div class="sidebar-brand">
						Proton
					</div>

					<ul class="sidebar-terms">
						<li><a href="index.html#">Terms</a></li>
						<li><a href="index.html#">Privacy</a></li>
						<li><a href="index.html#">Help</a></li>
						<li><a href="index.html#">About</a></li>
					</ul>

					<div class="copyright text-center">
						<small>Proton <i class="fa fa-coffee"></i> from <a href="http://www.cssmoban.com/" title="网页模板" target="_blank">网页模板</a></small>
					</div>
				</div>

			</div>
			<!-- end: Main Menu -->

		<!-- start: Content -->
		<!-- 可变内容区代码位置 -->
		<div class="main" style="background-color:#fff">
	    	
    <div class="layui-row">
        <div class="layui-col-md12">
            <div class="panel-heading">
                <h2><i class="fa fa-indent red"></i><strong>&nbsp;&nbsp;添加商品</strong></h2>
            </div>
        </div>
        <hr class="layui-bg-black">

        <div class="layui-col-md6 layui-col-md-offset3" style="margin-top: 30px;">
          <form class="layui-form" action="" method="post">

            <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">商品名称</label>
                <div class="layui-input-block">
                    <input type="text" name="goods_name" placeholder="例：兰蔻/法兰琳卡" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">市场价</label>
                <div class="layui-input-block">
                    <input type="text" name="market_price" placeholder="￥" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">现价</label>
                <div class="layui-input-block">
                    <input type="text" name="shop_price" placeholder="￥" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">上架</label>
                <div class="layui-input-block">
                    <input type="radio" name="is_up" value="1" title="是" checked>
                    <input type="radio" name="is_up" value="0" title="否">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">新品</label>
                <div class="layui-input-block">
                    <input type="radio" name="is_new" value="1" title="是" checked>
                    <input type="radio" name="is_new" value="0" title="否">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">热卖</label>
                <div class="layui-input-block">
                    <input type="radio" name="is_hot" value="1" title="是" checked>
                    <input type="radio" name="is_hot" value="0" title="否">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">商品类型</label>
                <div class="layui-input-block" style="width:150px;">
                    <select id="goods_type" lay-verify="" lay-filter="goods_type">
                      <option value="">请选择商品类型</option>
                      <?php if(is_array($goods_type)): foreach($goods_type as $key=>$v): ?><option value="<?php echo ($v["id"]); ?>"><?php echo ($v["name"]); ?></option><?php endforeach; endif; ?>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">商品规格项</label>
                <div class="layui-input-block spec_item">
                    <!-- <div class="layui-row">
                      <div class="layui-input-block">
                          <label class="layui-form-label" style="width:100px; margin-left:-140px">颜色</label>
                      </div>
                      <div class="layui-input-block" style="margin-left:0">
                          <div class="layui-col-md2">
                              <span class="layui-btn layui-btn-disabled" style="width:100px;"></span>
                              <button type="button" class="layui-btn layui-btn-normal" style="width:100px; margin-left: 0;">+</button>
                              <input type="text" class="layui-input" style="width:100px;" name="">
                          </div>
                      </div>
                    </div>

                    <table class="layui-table" lay-size="sm">
                        <thead height="40">
                          <tr>
                            <th width="120">规格总价</th>
                            <th width="120">库存</th>
                            <th width="400">规格描述</th>
                            <th width="50">操作</th>
                          </tr>
                        </thead>
                        <tbody>
                          <tr>
                            <td>贤心</td>
                            <td>贤心</td>
                            <td>2016-11-29</td>
                            <th>
                              <div class="layui-btn-group">
                                <button class="layui-btn layui-btn-primary layui-btn-sm"><i class="layui-icon"></i></button>
                              </div>
                            </th>
                          </tr>
                        </tbody>
                    </table>

                    <div class="layui-col-md1 layui-col-md-offset10">
                      <div class="grid-demo grid-demo-bg1">
                        <button class="layui-btn layui-btn-danger">规格录入</button>
                      </div>
                    </div> -->

                </div>


            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">分类类型</label>
                <div class="layui-input-block" style="width:150px;">
                    <select name="cate_id" lay-verify="">
                      <option value="">请选择分类类型</option>
                      <?php if(is_array($cate)): foreach($cate as $key=>$v): ?><option value="<?php echo ($v["id"]); ?>"><?php echo ($v["name"]); ?></option><?php endforeach; endif; ?>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">品牌类型</label>
                <div class="layui-input-block" style="width:150px;">
                    <select name="brand_id" lay-verify="">
                      <option value="">请选择品牌类型</option>
                      <?php if(is_array($brand)): foreach($brand as $key=>$v): ?><option value="<?php echo ($v["id"]); ?>"><?php echo ($v["name"]); ?></option><?php endforeach; endif; ?>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">商品图片</label>
                <div class="layui-input-block">
                    <div class="layui-upload">
                        <button type="button" class="layui-btn"  id="img">上传图片</button>
                        <div class="layui-upload-list">
                            <img class="layui-upload-img" id="demo1">
                            <p id="demoText"></p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">

                <div class="layui-input-block">
                    <script id="editor" name="desc" type="text/plain" style="width:900px;height:300px;"></script>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                  <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
          </form>
        </div>
    </div>


	    </div>
		<!-- end: Content -->
		<br><br><br>


		<div id="usage">
			<ul>
				<li>
					<div class="title">Memory</div>
					<div class="bar">
						<div class="progress">
						  	<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width: 50%"></div>
						</div>
					</div>
					<div class="desc">4GB of 8GB</div>
				</li>
				<li>
					<div class="title">HDD</div>
					<div class="bar">
						<div class="progress">
						  	<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" style="width: 25%"></div>
						</div>
					</div>
					<div class="desc">250GB of 1TB</div>
				</li>
				<li>
					<div class="title">SSD</div>
					<div class="bar">
						<div class="progress">
					  		<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width: 70%"></div>
						</div>
					</div>
					<div class="desc">700GB of 1TB</div>
				</li>
				<li>
					<div class="title">Bandwidth</div>
					<div class="bar">
						<div class="progress">
					  		<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="90" aria-valuemin="0" aria-valuemax="100" style="width: 90%"></div>
						</div>
					</div>
					<div class="desc">90TB of 100TB</div>
				</li>
			</ul>
		</div>

	</div><!--/container-->


	<div class="modal fade" id="myModal">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h4 class="modal-title">Warning Title</h4>
				</div>
				<div class="modal-body">
					<p>Here settings can be configured...</p>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
					<button type="button" class="btn btn-primary">Save changes</button>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->

	<div class="clearfix"></div>


	<!-- start: JavaScript-->
	<!--[if !IE]>-->

			<script src="/Public/Admin/assets/js/jquery-2.1.1.min.js"></script>

	<!--<![endif]-->

	<!--[if IE]>

		<script src="/Public/Admin/assets/js/jquery-1.11.1.min.js"></script>

	<![endif]-->

	<!--[if !IE]>-->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='assets/js/jquery-2.1.1.min.js'>"+"<"+"/script>");
		</script>

	<!--<![endif]-->

	<!--[if IE]>

		<script type="text/javascript">
	 	window.jQuery || document.write("<script src='assets/js/jquery-1.11.1.min.js'>"+"<"+"/script>");
		</script>

	<![endif]-->
	<script src="/Public/Admin/assets/js/jquery-migrate-1.2.1.min.js"></script>
	<script src="/Public/Admin/assets/js/bootstrap.min.js"></script>


	<!-- page scripts -->
	<script src="/Public/Admin/assets/plugins/jquery-ui/js/jquery-ui-1.10.4.min.js"></script>
	<script src="/Public/Admin/assets/plugins/touchpunch/jquery.ui.touch-punch.min.js"></script>
	<script src="/Public/Admin/assets/plugins/moment/moment.min.js"></script>
	<script src="/Public/Admin/assets/plugins/fullcalendar/js/fullcalendar.min.js"></script>
	<!--[if lte IE 8]>
		<script language="javascript" type="text/javascript" src="/Public/Admin/assets/plugins/excanvas/excanvas.min.js"></script>
	<![endif]-->
	<script src="/Public/Admin/assets/plugins/flot/jquery.flot.min.js"></script>
	<script src="/Public/Admin/assets/plugins/flot/jquery.flot.pie.min.js"></script>
	<script src="/Public/Admin/assets/plugins/flot/jquery.flot.stack.min.js"></script>
	<script src="/Public/Admin/assets/plugins/flot/jquery.flot.resize.min.js"></script>
	<script src="/Public/Admin/assets/plugins/flot/jquery.flot.time.min.js"></script>
	<script src="/Public/Admin/assets/plugins/flot/jquery.flot.spline.min.js"></script>
	<script src="/Public/Admin/assets/plugins/xcharts/js/xcharts.min.js"></script>
	<script src="/Public/Admin/assets/plugins/autosize/jquery.autosize.min.js"></script>
	<script src="/Public/Admin/assets/plugins/placeholder/jquery.placeholder.min.js"></script>
	<script src="/Public/Admin/assets/plugins/datatables/js/jquery.dataTables.min.js"></script>
	<script src="/Public/Admin/assets/plugins/datatables/js/dataTables.bootstrap.min.js"></script>
	<script src="/Public/Admin/assets/plugins/raphael/raphael.min.js"></script>
	<script src="/Public/Admin/assets/plugins/morris/js/morris.min.js"></script>
	<script src="/Public/Admin/assets/plugins/jvectormap/js/jquery-jvectormap-1.2.2.min.js"></script>
	<script src="/Public/Admin/assets/plugins/jvectormap/js/jquery-jvectormap-world-mill-en.js"></script>
	<script src="/Public/Admin/assets/plugins/jvectormap/js/gdp-data.js"></script>
	<script src="/Public/Admin/assets/plugins/gauge/gauge.min.js"></script>


	<!-- theme scripts -->
	<script src="/Public/Admin/assets/js/SmoothScroll.js"></script>
	<script src="/Public/Admin/assets/js/jquery.mmenu.min.js"></script>
	<script src="/Public/Admin/assets/js/core.min.js"></script>
	<script src="/Public/Admin/assets/plugins/d3/d3.min.js"></script>

	<!-- inline scripts related to this page -->
	<script src="/Public/Admin/assets/js/pages/index.js"></script>


	<script src="/Public/Admin/assets/js/jquery-2.1.1.min.js"></script>
	<script src="/Public/Admin/layui/layui.all.js"></script>



	<!-- end: JavaScript-->

</body>
</html>
<<script type="text/javascript">

	var upload,form,laydate,table;
	layui.use(['upload','form','laydate','table'], function(){
		upload =layui.upload;
		form =layui.form;
		laydate =layui.laydate;
		table =layui.table;


	})

</script>


  <!-- jquery -->
  <script type="text/javascript" src="/Public/Admin/assets/js/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="/Public/Admin/assets/js/jquery.validate.min.js"></script>
  <!-- jquery -->

  <!-- 百度编辑器is文件 -->
  <script type="text/javascript" charset="utf-8" src="/Public/Admin/ueditor/ueditor.config.js"></script>
  <script type="text/javascript" charset="utf-8" src="/Public/Admin/ueditor/ueditor.all.min.js"> </script>
  <!-- 百度编辑器is文件 -->

	<script type="text/javascript">
		$(function(){

      //初始化百度编辑器
      var ue = UE.getEditor('editor');

      //规格录入
      $('.spec_item').on('click','#spec_in',function(event) {


          var total_price = 0;//规格总价
          var spec_desc = '';//规格项描述
          var specItem_id = '';//规格规则
          var number = $(':text[name="number"]').val();//库存

          //抓取所有录入的规格项单价
          var price = $('.spec_item input[name="price"]');

          var inp_len = $('.spec_num').length;

          if(price.length!=inp_len){
            alert('请将规格信息填写完整');
            return false;
          }

          var numb = $('.spec_item input[name="number"]').val();

          if(numb=='' && !isNaN(numb)){
            alert('请输入库存且是数字类型');
            return false;
          }

          //循环累计规格项单价、规格项描述
          price.each(function(i,obj){
            total_price+=parseInt($(obj).val());
            spec_desc+=$(obj).prev().attr('spec-desc')+'；';
            specItem_id+='_'+$(obj).prev().attr('specItem-id');
          })
          console.log(specItem_id);
         // return false;

          $.ajax({
            type:'post',
            url:'<?php echo U("Admin/ajax/spec_into");?>',
            data:{
              'spec_rules':specItem_id,
              'number':number,
              'spec_price':total_price,
              'spec_desc':spec_desc,
            },
            datatype:'json',
            success:function(e){

              var html = '';
              html += '<div class="layui-row"><div class="layui-input-block" style="margin-left:0"><table class="layui-table" lay-size="sm">';
              html += '<thead height="40">';
              html += '<tr>';
              html += '<th width="120">规格总价</th>';
              html += '<th width="100">库存</th>';
              html += '<th width="400">规格描述</th>';
              html += '<th width="50">操作</th>';
              html += '</tr>';
              for(i in e){
                html += '<tbody>';
                html += '<tr>';
                html += '<td>'+e[i].spec_price+'</td>';
                html += '<td>'+e[i].number+'</td>';
                html += '<td>'+e[i].spec_desc+'</td>';
                html += '<th>';
                html += '<button class="layui-btn layui-btn-primary layui-btn-sm"><i class="layui-icon"></i></button>';
                html += '</th>';
                html += '</tbody></div></div>';
              }
              $('.spec_list').html(html);
            }
          })

      });

      //根据所选商品类型显示相应的规格项
      form.on('select(goods_type)', function(data){
          // console.log(data.elem); //得到select原始DOM对象
          // console.log(data.value); //得到被选中的值
          // console.log(data.othis); //得到美化后的DOM对象

          // 获取被选中项的商品id
          var id = data.value;

          $.ajax({
            type:'get',
            url:'<?php echo U("Admin/ajax/getSpec");?>',
            data:{
              'id':id,
            },
            datatype:'json',
            success:function(j){
              var html = '';
              for(i in j){

                html += '<div class="layui-row spec_num">';
                html += '<div class="layui-input-block">';
                html += '<label class="layui-form-label" style="width:100px; margin-left:-140px">'+j[i].spec_name+'</label>';
                html += '</div>';
                html += '<div class="layui-input-block" style="margin-left:0">';
                for(s in j[i]['spec_item']){
                html += '<div class="layui-col-md2">';
                html += '<span class="layui-btn layui-btn-primary" style="width:100px;">'+j[i]['spec_item'][s]['name']+'</span>';
                var desc = j[i].spec_name+':'+j[i]['spec_item'][s]['name'];
                html += '<button type="button" class="layui-btn layui-btn-normal add" specItem-id="'+j[i]['spec_item'][s]['id']+'" spec-desc="'+desc+'" style="width:100px; margin-left: 0;">+</button>';
                html += '</div> ';
                }
                html += '</div>';
                html += '</div>';
              }

                //追加库存
                html += '<div class="layui-row">';
                html += '<div class="layui-input-block">';
                html += '<label class="layui-form-label" style="width:100px; margin-left:-170px">库存</label>';
                html += '</div>';
                html += '<div class="layui-input-block" style="margin-left:0">';
                html += '<div class="layui-col-md2">';
                html += '<input type="text" class="layui-input" name="number" style="width:100px; border:1px solid #c9c9c9">';
                html += '</div> ';
                html += '</div>';
                html += '</div>';

                //添加规格输入按钮
                var htmlluru = html+'<div id="spec_in" class="layui-col-md1 layui-col-md-offset10"><div class="grid-demo grid-demo-bg1"><button  type="button" class="layui-btn layui-btn-danger">规格录入</button></div></div><div class="spec_list"></div>';


                $('.spec_item').html(htmlluru);

              $('.add').click(function(){

                  var icon = $(this).text();
                  if(icon=='+'){
                    //优化再次点击继续累加文本框的问题
                    $(this).parent().parent().find(':text[name="price"]').remove();
                    $(this).parent().parent().find(':button').text('+');

                    $(this).text('-');
                    var inp = '<input type="text" class="layui-input" placeholder="￥" name="price" style="width:100px; text-align:center">';
                    $(this).after(inp);
                  }else{

                    $(this).text('+');
                    $(this).next().remove();
                  }
              })
            }
          })
      });


      $('#edui1').css('z-index','900');

        //商品图片上传
        var uploadInst = upload.render({
            elem: '#img',
            url: "<?php echo U('admin/ajax/img');?>",
            before: function(obj){
              //预读本地文件示例，不支持ie8
              obj.preview(function(index, file, result){
                $('#demo1').attr('src', result); //图片链接（base64）
              });
            },
            done: function(res){
              //如果上传失败
              if(res > 0){
                return layer.msg('上传成功');
              }else{
                return layer.msg('上传失败');
              }
              //上传成功
            },
            error: function(){
              //演示失败状态，并实现重传
              var demoText = $('#demoText');
              demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
              demoText.find('.demo-reload').on('click', function(){
                uploadInst.upload();
              });
            }
        })

		})
	</script>